<?php
$cata_id = $_POST['recata_id'];
$cata_name = $_POST['recata'];
session_start();
if(!isset($_SESSION['username'])){
    echo '<script>alert("未登录");location="./login.html"</script>';
    exit(0);
}
$cata_user = $_SESSION['username'];
if ($cata_name == '') {
    echo '<script>alert("不能为空");history.go(-1);</script>';
    exit(0);
}
if (strlen($cata_name) > 256) {
    echo '<script>alert("内容过长");history.go(-1);</script>';
    exit(0);
}

include('./connect.php');
if ($conn->connect_error) {
    echo '数据库连接失败！';
    exit(0);
} else {
    $sql_update = "update cata set cata_name = '$cata_name' where cata_id = '$cata_id'";
    $res_update = $conn->query($sql_update);
    if ($res_update) {
    } else {
        echo "<script>alert('系统繁忙，请稍候！');</script>";
    }
}
?>